package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.IView.IMediaListByRegionIdView;

import com.cloudsigns.factorymanager2.engineering.bean.MediaBean;
import com.cloudsigns.factorymanager2.engineering.model.IMediaListByRegionIdModel;
import com.cloudsigns.factorymanager2.engineering.model.MediaListByRegionIdModel;

import java.util.List;

/**
 * Created by tony on 2018/5/5.
 * [ [项目部-媒体库]根据id获取媒体列表 ]
 */

public class MediaListByIdPresenter {

    private IMediaListByRegionIdView view;
    private IMediaListByRegionIdModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public MediaListByIdPresenter(IMediaListByRegionIdView view) {
        this.view = view;
        this.model = new MediaListByRegionIdModel();
    }

    public void getMediaListById() {


        model.getMediaListById(view.getId(),view.getEngineeringDeptOrderCategoryEnum(),new MediaListByRegionIdModel.OnMediaListByIdListener() {
            @Override
            public void getMediaListByIdSuccessed(final List<MediaBean> mediaRegionBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getMediaListByIdSuccessed(mediaRegionBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getMediaListByIdFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showFailedError(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
